package br.com.gbvbahia.mybooks;

import java.io.Serializable;

import android.os.Bundle;
import br.com.gbvbahia.mybooks.fragment.FragmentTransfer;
import br.com.gbvbahia.mybooks.fragment.ListarPrateleirasFragment;
import br.com.gbvbahia.mybooks.fragment.LivroCountFragment;
import br.com.gbvbahia.mybooks.fragment.PrateleiraCadastrarFragment;
import br.com.gbvbahia.mybooks.modelos.PrateleiraVO;

public class Prateleiras extends ActivityMae implements FragmentTransfer {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.prateleiras);
	}

	@Override
	public void updateFragment(int idFragmentToUpdate, Serializable obj) {
		switch (idFragmentToUpdate) {
		//Uma prateleira foi selecionada na lista
		case R.layout.prat_listar:
			PrateleiraCadastrarFragment frag = (PrateleiraCadastrarFragment) getSupportFragmentManager()
					.findFragmentByTag("cadastroPratfrag");
			frag.setPrateleiraCad((PrateleiraVO) obj);
			break;
			//Uma prateleira foi salva/atualizada
		case R.layout.frag_prat_edit:
			ListarPrateleirasFragment frags = (ListarPrateleirasFragment) getSupportFragmentManager()
					.findFragmentByTag("fragPratlista");
			frags.startTransacao(frags);
			LivroCountFragment fragCount = (LivroCountFragment) getSupportFragmentManager()
					.findFragmentByTag("fragPratcount");
			fragCount.onResume();
			break;
		}
	}

}
